class StoreChunks {
  addChunkStore(name, data) {
    //  存储 hash arr
    const arr = this.getChunkArr(name)
    if (arr) {
      this.saveChunkArr(name, [...arr, data])
    } else {
      this.saveChunkArr(name, [data])
    }
  }
  saveChunkArr(name, data) {
    localStorage.setItem(name, JSON.stringify(data))
  }
  getChunkArr(name) {
    const data = window.localStorage.getItem(name)
    if (data && data !== undefined) {
      return JSON.parse(data)
    }
    return false
  }
}

export const storeChunks = new StoreChunks()
